SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 69599: A WHERE clause that contains an AND condition returns incorrect results when the first two arguments of the AND condition are the same

DetailsAboutRate It

If you use a WHERE clause that contains an AND condition and the first two arguments in the AND condition are identical, an incorrect number of observations might be returned.

The following code example illustrates the issue. After the code executes, multiple observations occur, but the expectation is that one observation should be returned:

data one;
infile datalines truncover;
input x1 $ x2 $; 
datalines;
house 
house car
house house
;
run;
data two; 
  set one; 
  where indexw("house", x1) and indexw("house", x2); 
run; 

No notes, warnings, or errors are issued in the SAS® log to indicate that an incorrect number of observations has been returned.

Workarounds

There are two workarounds. 

The first workaround is to change the WHERE clause to have the following syntax:

 where 0 < indexw("house", x1) and 0 < indexw("house", x2); 

After you make that change, one observation is returned, as expected. 

The second workaround is to substitute an IF statement in place of the WHERE clause. Here is an example:

data two; 
  set one; 
  if indexw("house", x1) and indexw("house", x2); 
run; 

Using an IF statement also returns the correct number of observations, which is one in this scenario.   



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemBase SASz/OS9.4 TS1M19.4 TS1M8
z/OS 64-bit9.4 TS1M19.4 TS1M8
Microsoft® Windows® for x649.4 TS1M19.4 TS1M8
Microsoft Windows 8 Enterprise 32-bit9.4 TS1M19.4 TS1M8
Microsoft Windows 8 Enterprise x649.4 TS1M19.4 TS1M8
Microsoft Windows 8 Pro 32-bit9.4 TS1M19.4 TS1M8
Microsoft Windows 8 Pro x649.4 TS1M19.4 TS1M8
Microsoft Windows 8.1 Enterprise 32-bit9.4 TS1M19.4 TS1M8
Microsoft Windows 8.1 Enterprise x649.4 TS1M19.4 TS1M8
Microsoft Windows 8.1 Pro 32-bit9.4 TS1M19.4 TS1M8
Microsoft Windows 8.1 Pro x649.4 TS1M19.4 TS1M8
Microsoft Windows 109.4 TS1M19.4 TS1M8
Microsoft Windows Server 20089.4 TS1M19.4 TS1M8
Microsoft Windows Server 2008 R29.4 TS1M19.4 TS1M8
Microsoft Windows Server 2008 for x649.4 TS1M19.4 TS1M8
Microsoft Windows Server 2012 Datacenter9.4 TS1M19.4 TS1M8
Microsoft Windows Server 2012 R2 Datacenter9.4 TS1M19.4 TS1M8
Microsoft Windows Server 2012 R2 Std9.4 TS1M19.4 TS1M8
Microsoft Windows Server 2012 Std9.4 TS1M19.4 TS1M8
Windows 7 Enterprise 32 bit9.4 TS1M19.4 TS1M8
Windows 7 Enterprise x649.4 TS1M19.4 TS1M8
Windows 7 Home Premium 32 bit9.4 TS1M19.4 TS1M8
Windows 7 Home Premium x649.4 TS1M19.4 TS1M8
Windows 7 Professional 32 bit9.4 TS1M19.4 TS1M8
Windows 7 Professional x649.4 TS1M19.4 TS1M8
Windows 7 Ultimate 32 bit9.4 TS1M19.4 TS1M8
Windows 7 Ultimate x649.4 TS1M19.4 TS1M8
64-bit Enabled AIX9.4 TS1M19.4 TS1M8
64-bit Enabled Solaris9.4 TS1M19.4 TS1M8
HP-UX IPF9.4 TS1M19.4 TS1M8
Linux for x649.4 TS1M19.4 TS1M8
Solaris for x649.4 TS1M19.4 TS1M8
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.